$.ajaxSetup({
  complete : function(xhr, status) {
    //拦截器实现超时跳转到登录页面
    // 通过xhr取得响应头
    var REDIRECT = xhr.getResponseHeader("REDIRECT");
    //如果响应头中包含 REDIRECT 则说明是拦截器返回的
    if (REDIRECT == "REDIRECT")
    {
      var win = window;
      while (win != win.top)
      {
        win = win.top;
      }
      //重新跳转到 login.html
      win.location.href = xhr.getResponseHeader("CONTEXTPATH");
    }
  }
});
//弹出，3秒消失
function popup(msg) {
    $('body').append('<div id="over_container"><div id="over_message">'+msg+'</div></div>')
    setTimeout(function () {
        $('#over_container').remove();
    }, 3000)
}

$(function () {
  $('._j_close').click(function () {
    $('#_j_layer_0').hide();
  })

  $('.collect_icon').click(function () {
    if ($(this).hasClass('on-i02')) {
      $('#_j_layer_0').show();
      $('.collect_icon').removeClass('on-i02')
    } else {
      $(this).addClass('on-i02');
    }
  });

  $(window).scroll(function () {
    if ($(this).scrollTop() > 280) {
      $('.toolbar-item-top').show();
    } else {
      $('.toolbar-item-top').hide();
    };
  });

  $('.toolbar-item-top').click(function () {
    $('html, body').animate({
      scrollTop: 0
    }, 250);
    return false;
  });
});

//定义api的域名与端口
var baseUrl = "http://localhost:8888";